package com.hmall.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.order.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * @Description:
 * @Author: 315QK
 * @Date: 2021/12/21/10:52
 */
public interface OrderMapper extends BaseMapper<Order> {

    @Insert("insert into tb_order (total_Fee,payment_type,user_id,status) values (#{totalFee},#{paymentType},#{userId},#{status})")
    public void addOrder(Order order);



    @Update("update tb_order set status=2 where id=#{orderId}")
    void updateWithId(Long orderId);

    @Update("update tb_order set status=5 where status=#{status} and (ROUND((UNIX_TIMESTAMP(#{now})-UNIX_TIMESTAMP(create_time))/60))>3 ")
    void updateOrders(@Param("status") int status,
                      @Param("now") LocalDateTime now);
}
